---
seotitle: API Calls with Encore.ts
seodesc: Learn how to make type-safe API calls in TypeScript with Encore.ts
title: API Calls
subtitle: Making API calls is as simple as making function calls
lang: ts
---

Calling API endpoints between services, i.e. service-to-service calls, looks like regular function calls with Encore.ts. This gives you a simple monolith-like developer experience, even when you use multiple services.
The only thing you need to do is import the service you want to call from `~encore/clients` and then call its API endpoints like functions.

This works because, when compiling your application, Encore uses [static analysis](/docs/ts/concepts/application-model) to parse all APIs and make them available through the `~encore/clients` module for internal calls.
You get all the benefits of function calls, like compile-time checking of all the parameters and auto-completion in your editor, while still allowing the division of code into logical components, services, and systems.

### Example

In the example below, we import the service `hello` and call the `ping` endpoint using a function call to `hello.ping`.

```typescript
import { hello } from "~encore/clients"; // import 'hello' service

export const myOtherAPI = api({}, async (): Promise<void> => {
  const resp = await hello.ping({ name: "World" });
  console.log(resp.message); // "Hello World!"
});
```

<GitHubLink
    href="https://github.com/encoredev/examples/tree/main/ts/simple-event-driven"
    desc="Simple microservices example application with service-to-service API calls."
/>
